<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>

<script type="text/javascript">
$(document).ready(function() {
    $('#eventTable').dataTable();
} );
</script>
<div style="margin-top: 5px; margin-bottom: 15px">
<h2 style="display: inline"><s:text name="listEvents.header"></s:text></h2>
<s:if test="#session.loginToken.rights.contains('event_create')">
	<s:url id="createEventInputUrlId" action="createEventInput"
		namespace="/"></s:url>
	<div style="float: right;"><s:a href="%{createEventInputUrlId}"  title="%{getText('listEvents.newEvent')}">
		<img src="image/icons/0009_add.png" width="24" height="24" alt="new"
			border="0">
	</s:a></div>
</s:if>
</div>
<table id="eventTable" class="green">
	<thead>
		<tr>
			<th>ID</th>
			<th><s:text name="eventBean.eventName"></s:text></th>
			<th><s:text name="eventBean.eventLocation"></s:text></th>
			<th><s:text name="eventBean.eventDate"></s:text></th>
			<th><s:text name="eventBean.eventOwner" /></th>
			<th><s:text name="listEvents.actions"></s:text></th>
		</tr>
	</thead>
	<tbody>
		<s:iterator value="eventList">
			<tr>
				<td><s:property value="eventId"></s:property></td>
				<td><s:property value="eventName"></s:property></td>
				<td><s:property value="eventLocation"></s:property></td>
				<td><s:date name="eventDate" format="dd.MM.yyyy"></s:date></td>
				<td><s:property value="eventOwner.email"></s:property></td>
				<td>
				<!-- Event ansehen -->
				<s:url id="eventUrlId" action="showEvent" namespace="/">
					<s:param name="eventId">
						<s:property value="eventId"></s:property>
					</s:param>
				</s:url> 
				<s:a href="%{eventUrlId}" title="%{getText('listEvents.showEvent')}">
					<img src="image/icons/0047_id.png" width="24" height="24"
						alt="event" border="0" >
				</s:a>
				<!-- Event bearbeiten -->
				<s:if
					test="#session.loginToken.rights.contains('event_edit') || eventOwner.userId == #session.loginToken.userId">
					<s:url id="editEventUrlId" action="editEventInput" namespace="/">
						<s:param name="eventId">
							<s:property value="eventId"></s:property>
						</s:param>
					</s:url>
					<s:a href="%{editEventUrlId}" title="%{getText('listEvents.editEvent')}">
						<img src="image/icons/0037_notepad.png" width="24" height="24"
							alt="profile" border="0">
					</s:a>
				</s:if>
				<!-- Event löschen -->
				<s:if
					test="#session.loginToken.rights.contains('event_delete') || eventOwner.userId == #session.loginToken.userId">
					<s:url id="deleteEventUrlId" action="deleteEvent" namespace="/">
						<s:param name="eventId">
							<s:property value="eventId"></s:property>
						</s:param>
					</s:url>
					<s:a href="%{deleteEventUrlId}" title="%{getText('listEvents.deleteEvent')}">
						<img src="image/icons/0049_trash.png" width="24" height="24"
							alt="delete" border="0" onclick="return ask_first(this);">
					</s:a>
				</s:if>
				</td>
			</tr>
		</s:iterator>
	</tbody>
</table>
<div id="link" style="float: left">
<s:url id="listEventsInputUrlId" action="listEvents" namespace="/">
	<s:param name="showOnlyOwn">true</s:param>
</s:url>
<s:a href="%{listEventsInputUrlId}"><s:text name="listEvents.showOnlyOwn"></s:text></s:a>
<s:url id="listEventsAllInputUrlId" action="listEvents" namespace="/"></s:url>
<s:a href="%{listEventsAllInputUrlId}"><s:text name="listEvents.showAll"></s:text></s:a>
</div>